var proClassList;
$(function () {
    if($('#proClassList').length>0){
        proClassList = $.fn.bsgrid.init('proClassList', {
            url:'../../doAdminAction.php?act=classList',                //数据地址
            pageSizeSelect: true,
            pageSize: 10,
            stripeRows: true,
            displayBlankRows: false
        });
    }
});
var proClass={
    operate:function(record, rowIndex, colIndex, options){
        var id=proClassList.getRecordIndexValue(record, 'id');
        var operate='';
        operate+='<a href="proClassEdit.php?id=' + id + '">编辑</a> <a href="javascript:;" onclick="proClass.del(' + id + ')">删除</a>';
        return operate;
    },
    state:function(record, rowIndex, colIndex, options){
        var state=proClassList.getRecordIndexValue(record, 'state');
        if(state==1) return '<span class="sui-text-success">有效</span>';
        else if(state==0) return '<span class="sui-text-disabled">无效</span>'
    },
    img:function(record, rowIndex, colIndex, option){
        var imgUrl=proClassList.getRecordIndexValue(record, 'cImg');
        if(!imgUrl) return '';
        else return '<img src="../../uploadimg/cate/'+imgUrl+'" width="50" style="padding:5px;">';
    },
    //删除产品分类
    del:function(id){
        table.del({
            "id":id,
            "url":'../../doAdminAction.php?act=classDel'
        })
    }
}
$("#proClassAdd").validate({
    rules:{
        cName:{required:true},
    }
})
$("#proClassEdit").validate({
    rules:{
        cName:{required:true}
    }
})